<template>
	<view class="content">
		<view class="title"> {{brandName}}	{{xingHao}}	</view>
		
		 
		 <view class="padding flex flex-wrap justify-between align-center ">
			<view class="price">￥{{showPrice}}</view>
		<view><button class="cu-btn round bg-olive" @click="ShareLink">分享链接</button> </view>
		 </view>
		 
		 		 
		<view class="title">车辆档案	</view>
		 <view class="tui-table-view">
		    <view class="tui-col-3">
		      <view class="xiaoTitle"> 表显里程</view> 
		      <view>{{Wkm}}万公里</view>
		    </view>
		    <view class="tui-col-3">
		       <view class="xiaoTitle">上牌时间</view>  
		      <view>{{regdate}}</view>
		    </view>
		    <view class="tui-col-3">
		     <view class="xiaoTitle"> 变速箱</view>
		     <view>  {{speedAssembly}} </view>
		    </view>
			
		    <view class="tui-col-3">
		     <view class="xiaoTitle"> 排放量</view>
		     <view>{{engineCC}}{{TL}}</view>
		    </view>
		    <view class="tui-col-3">
		     <view class="xiaoTitle"> 交强险到</view>
		     <view>{{jQXDaoQi}}</view>
		    </view>
		    <view class="tui-col-3">
		      <view class="xiaoTitle"> 商业险到</view>
		      <view>{{sYxDaoQi}}</view>
		    </view>
			 
			
		  </view> 
		<view class="art-content">
			<text>{{showTxt}}</text>			
			<view v-for="(value,index) in Carimgs" :key="value"  >
					<image :src="value" mode="scaleToFill"  @click="preImg(index)"></image>
			</view>	
								
			<text v-if="showHide">{{hideTxt}}</text>	
		</view>
		
		 <view class="tui-table-view">
			 <view class="tui-col-3" v-if="showHide" >
			   <view class="xiaoTitle"> 店名</view>
			   <view>{{ShopName}}</view>
			 </view>
			 
			<view class="tui-col-3" v-if="showHide" >
			  <view class="xiaoTitle"> 内部卖价</view>
			  <view>{{sellPrice}}</view>
			</view>
			
			<view class="tui-col-3" v-if="showHide" >
			  <view class="xiaoTitle"> 成本</view>
			  <view>{{costPrice}}</view>
			</view>
			
			<view class="tui-col-3" v-if="showHide" >
			  <view class="xiaoTitle"> 成交价</view>
			  <view>{{closePrice}}</view>
			</view>
		</view>
		
	</view>
</template>

<script>
import service from '../../service.js';
 var _self;
	export default {
		data() {
			return {
				brandName:'',
				xingHao:'',
				Carimgs:[],
				Wkm:'',
				regdate:'',
				speedAssembly:'',
				engineCC:'',
				TL:'',
				jQXDaoQi:'',
				sYxDaoQi:'',
				showTxt:'',
				hideTxt:'',
				showPrice:0,
				closePrice:0,
				costPrice:0,
				sellPrice:0,
				showHide:service.showHide,
				userinfo:service.getUsers(),
				ShopName:'',
				pageid:0,
				imgShow: false,
			}
		},
		onLoad:function(e){
			_self=this; 
			this.pageid=e.carid
		// 	console.log(this.userinfo);
		// console.log(this.userinfo.RoleName);
			uni.request({
				//url: 'https://unidemo.dcloud.net.cn/api/news/36kr/'+e.newsid,
				url: service.BaseUrl+'api/apiCar/GetCarByid',
				method: 'POST',
				data: {
					ID:e.carid,
					Token: service.getUsers().Token
				},
				success: res => {
					if(res.data.Code==1){
						var dt=res.data.Data;
						console.log(dt);
						_self.brandName=dt.brandName;
						_self.xingHao=dt.xingHao;
						_self.Carimgs=dt.Carimgs;
						_self.Wkm=dt.Wkm;
						_self.regdate=dt.regdate.substring(0,10);
						_self.speedAssembly=dt.speedAssembly;
						_self.engineCC=dt.engineCC;
						var today =parseInt(new Date().getTime() / 1000);
						_self.jQXDaoQi =service.FormatDate(dt.jQXDaoQi);
						_self.sYxDaoQi =service.FormatDate(dt.sYxDaoQi);
						 _self.showTxt=dt.showTxt;
						_self.TL=dt.hasT?'T':'L';
						_self.hideTxt=dt.hideTxt;						
						_self.sellPrice=dt.sellPrice;
						_self.showPrice=dt.showPrice;
						_self.costPrice=dt.costPrice;
						_self.closePrice=dt.closePrice;
						_self.ShopName=dt.ShopName;
					}
					else{
						uni.showToast({
							title:"查询失败"
						}) 
					}
				
				},
				fail: () => {},
				complete: () => {}
			});
			
			
		},
		methods: { 
			ShareLink(){
				uni.setClipboardData({
					  data: service.BaseUrl+'index.html#/pages/carinfo/carDetail?carid='+_self.pageid,
					    success: function () {
							uni.showToast({
								title:"链接已复制，赶快在微信或qq粘贴分享吧"
							})
					       
					    }
				});
				 console.log(service.BaseUrl+'ndex.html#/pages/carinfo/carDetail?carid='+_self.pageid);
			}
			,
			preImg(index) {
				if (_self.imgShow) { //防止点击过快导致重复调用 
					return;
				}
				_self.imgShow = true;
				setTimeout(() => {
					_self.imgShow = false;
				}, 1000)
				console.log(_self.data)
				setTimeout(() => {
					uni.previewImage({
						current: index,
						urls: _self.Carimgs
					})
				}, 150)
			}
		}
		
	}
</script>

<style>
.content{
	display: flex; 
	flex-direction: column;
	padding-left:15upx;
	padding-right:15upx;
	}
.price{
	color: #f96e39;
	font-size: 40rpx;
	margin-top: 15upx;
}
			
.title{
	line-height: 2em;font-weight: 700;font-size: 38rpx;
	
}

.tui-table-view{
  display: -webkit-flex;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  width: 100%;
}
.tui-col-3{
 flex: 0 0 auto;
  width: 33.33333333%; 
   text-align: center; 
  padding: 15rpx 0;
  font-size: 34upx;
}
.xiaoTitle{
	font-size: 28upx;
	 color: #797979;
}

.art-content{line-height:2em ;}
</style>
